import {
  createStore
} from 'vuex'
import createPersistedState from "vuex-persistedstate";

const store = createStore({
  state: {
    msg: {}
  },
  mutations: {
    userMsg(state, data) {
      state.msg = data
    },
    // 改变头像地址
    userAvatar(state, data) {
      state.msg.avatar = data
    }
  },
  actions: {
    userMsg({
      commit
    }, data) {
      commit('userMsg', data)
    },
    userAvatar({
      commit
    }, data) {
      commit('userAvatar', data)
    }
  },
  plugins: [createPersistedState()],
})

export default store